<?php /* D:\phpStudy\PHPTutorial\WWW\laravel-admin\resources\views/admin/category/categoryEdit.blade.php */ ?>
<div id="app">
    <section class="content-header">
        <h1>
            <small>分类编辑</small>
        </h1>

    </section>

    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box box-info">
                    <div class="box-header with-border">
                        <div class="box-tools">
                            <div class="btn-group pull-right" style="margin-right: 5px">
                                <a href="/admin/category/index" class="btn btn-sm btn-default" title="分类列表"><i class="fa fa-list"></i><span class="hidden-xs">&nbsp;分类列表</span></a>
                            </div>
                        </div>

                        <span>
    <a class="btn btn-sm btn-primary grid-refresh" title="刷新"><i class="fa fa-refresh"></i><span class="hidden-xs"> 刷新</span></a>
    <a class="btn btn-sm btn-primary" onclick="javascript:history.go(-1);" title="返回"> <span class="hidden-xs"> 返回</span></a>
  </span>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start -->
                    <form id="editForm"  accept-charset="UTF-8" class="form-horizontal" enctype="multipart/form-data" pjax-container>
                        <div class="box-body">
                            <div class="fields-group">

                                <div class="form-group  ">
                                    <label for="cate_name" class="col-sm-2  control-label">所属渠道</label>
                                    <div class="col-sm-8">
                                        <div class="input-group">
                                            <?php echo e($cha_name, false); ?>

                                        </div>
                                    </div>
                                </div>

                                <div  class="form-group pid-div"  >
                                    <label for="pid" class="col-sm-2  control-label">上级分类</label>
                                    <div class="col-sm-8">
                                        <select id="pid" class="form-control pid"   name="pid" data-value="" >
                                            <option <?php if(0==$data['pid']): ?> selected <?php endif; ?> value="0">顶级分类</option>
                                            <?php if($list): ?>
                                                <?php $__currentLoopData = $list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k=>$v): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <option <?php if($v['cate_id']==$data['pid']): ?> selected <?php endif; ?> value="<?php echo e($v['cate_id'], false); ?>"><?php echo e($v['level_str'], false); ?><?php echo e($v['cate_name'], false); ?></option>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            <?php endif; ?>
                                        </select>
                                    </div>
                                </div>



                                <div class="form-group  ">
                                    <label for="cate_name" class="col-sm-2  control-label">分类名称</label>
                                    <div class="col-sm-8">
                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="fa fa-pencil fa-fw"></i></span>
                                            <input type="text" id="cate_name" name="cate_name" value="<?php echo e($data['cate_name'], false); ?>" class="form-control cate_name" placeholder="输入 分类名称" />
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group  ">
                                    <label for="cate_note" class="col-sm-2  control-label">分类简单阐释</label>
                                    <div class="col-sm-8">
                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="fa fa-pencil fa-fw"></i></span>
                                            <input   type="text" id="cate_note" name="cate_note" value="<?php echo e($data['cate_note'], false); ?>" class="form-control cate_note" placeholder="输入 分类简单阐释" />
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group  ">
                                    <label for="cate_code" class="col-sm-2  control-label">类目码</label>
                                    <div class="col-sm-8">
                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="fa fa-pencil fa-fw"></i></span>
                                            <input type="text" id="cate_code" name="cate_code" value="<?php echo e($data['cate_code'], false); ?>" class="form-control cate_code" placeholder="输入 类目码" />
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group  ">
                                    <label for="cate_code_name" class="col-sm-2  control-label">类目名称</label>
                                    <div class="col-sm-8">
                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="fa fa-pencil fa-fw"></i></span>
                                            <input type="text" id="cate_code_name" name="cate_code_name" value="<?php echo e($data['cate_code_name'], false); ?>" class="form-control cate_code_name" placeholder="输入 类目名称" />
                                        </div>
                                    </div>
                                </div>


                                <div class="form-group  ">
                                    <label for="img" class="col-sm-2  control-label">分类logo</label>
                                    <div class="col-sm-8">
                                        <input type="file" id="img" class="img" name="img" data-initial-preview="<?php echo e($data['cate_pic'], false); ?>" />
                                    </div>
                                </div>

                                <div class="form-group  ">
                                    <label for="p_sort" class="col-sm-2  control-label">分类排序</label>
                                    <div class="col-sm-8">
                                        <div class="input-group">
                                            <input style="width: 100px" type="text" id="p_sort" name="p_sort" value="<?php echo e($data['p_sort'], false); ?>" class="form-control p_sort"   />
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group  ">
                                    <label for="is_del" class="col-sm-2  control-label">是否删除</label>
                                    <div class="col-sm-8">
                                        <label class="radio-inline">
                                            <input type="radio" name="is_del" value="0" class="minimal is_del" <?php if($data['is_del']==0): ?> checked  <?php endif; ?>   />否
                                        </label>
                                        <label class="radio-inline">
                                            <input type="radio" name="is_del" value="1" class="minimal is_del"  <?php if($data['is_del']==1): ?> checked  <?php endif; ?>  />是
                                        </label>
                                    </div>
                                </div>
                                <div class="form-group  ">
                                    <label for="is_hidden" class="col-sm-2  control-label">是否隐藏</label>
                                    <div class="col-sm-8">
                                        <label class="radio-inline">
                                            <input type="radio" name="is_hidden" value="1" class="minimal is_hidden" <?php if($data['is_hidden']==1): ?> checked  <?php endif; ?> />是
                                        </label>
                                        <label class="radio-inline">
                                            <input type="radio" name="is_hidden" value="2" class="minimal is_hidden"  <?php if($data['is_hidden']==2): ?> checked  <?php endif; ?> />否&nbsp;&nbsp;
                                        </label>
                                    </div>
                                </div>
                                <div class="form-group  ">
                                    <label for="cate_hot_search" class="col-sm-2  control-label">热门搜索标签</label>
                                    <div class="col-sm-8">
                                        <textarea name="cate_hot_search" class="form-control cate_hot_search" rows="5" placeholder="输入 热门搜索标签"  ><?php echo e($data['cate_hot_search'], false); ?></textarea>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!-- /.box-body -->

                        <div class="box-footer">
                            <?php echo csrf_field(); ?>
                            <input type="hidden" name="cate_id" value="<?php echo e($data['cate_id'], false); ?>">
                            <div class="col-md-2">
                            </div>
                            <div class="col-md-8">
                                <div class="btn-group pull-right">
                                    <button type="button" onclick="tijiao()" class="btn btn-primary">编辑</button>
                                </div>

                                <div class="btn-group pull-left">
                                    <button type="reset" class="btn btn-warning">重置</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>

            </div></div>
    </section>
</div>
<script data-exec-on-popstate>
    $(function () {

        //刷新
        $('.grid-refresh').on('click', function() {
            $.pjax.reload('#pjax-container');
            toastr.success('刷新成功 !');
        });

        var cate_id="<?php echo e($data['cate_id'], false); ?>";
        $("input.img").fileinput({
            "overwriteInitial":true,
            "initialPreviewAsData":true,
            "browseLabel":"\u6d4f\u89c8",
            "showRemove":false,
            "showUpload":false,
            "dropZoneEnabled":false,
            "deleteExtraData":{
                "cate_id":cate_id,
                "_token":LA.token,
            },
            "deleteUrl":"http://www.laras.com/admin/category/delImg",
            "allowedFileTypes":["image"]}) ;

        $('#img').on('filesuccessremove', function(event, id) {
            console.log(id);
            if (some_processing_function(id)) {
                console.log('Uploaded thumbnail successfully removed');
            } else {
                return false;
            }
        });

        $('.p_sort:not(.initialized)')
            .addClass('initialized')
            .bootstrapNumber({
                upClass: 'success',
                downClass: 'primary',
                center: true
            });
    });


    function tijiao(){
        var data=new FormData($("#editForm")[0]);
        $.ajax({
            url:"/admin/category/edit",
            type:'post',
            data:data,
            dataType:'json',
            processData: false,
            contentType: false,
            success:function(m){
                if(m.status==1){
                    toastr.success(m.message);
                }else{
                    swal(m.message, '', 'error');
                }
            }
        });
    }
</script>